package com.xy.iot.common.result;

import com.alibaba.fastjson.annotation.JSONField;
import com.xy.iot.common.message.BaseByteArray;

/**
 * @author Administrator
 * @create 2018-05-08 16:03
 * @desc byte数组数据
 */
public class ByteArrayData implements BaseByteArray {
    /**
     * 消息长度
     */
    private final int length;
    /**
     * 消息数据
     */
    @JSONField(serialize = false)
    private final byte[] data;

    public ByteArrayData(byte[] data) {
        this.data = data;
        this.length = data.length;
    }

    @Override
    public int getLength() {
        return length;
    }

    @Override
    public byte[] toBytes() {
        return data;
    }

}
